﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcSystemsCommander.Extensions.Html
{
    public static class HtmlExtensions
    {
        public static MvcHtmlString CustomValidationSummary(this HtmlHelper helper)
        {
            var html = string.Empty;
            foreach (var item in helper.ViewData.ModelState)
            {
                if (item.Value.Errors.Any())
                {
                    foreach (ModelError e in item.Value.Errors)
                    {
                        html += e.ErrorMessage;
                    }
                }
            }

            return MvcHtmlString.Create(html);
        }
    }
}